#pragma once
#include <iostream>
#include <string>

#ifdef _WIN32
#include <windows.h>
#else
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include <cstring>
#include <stdexcept>
#endif

class MMAP {
private:
#ifdef _WIN32
    HANDLE m_file_handle;
    LARGE_INTEGER m_file_size;
    HANDLE m_mapping_handle;
#else
    int m_file_descriptor;
    size_t m_file_size;
#endif
    void* m_mapped_ptr;

public:
    MMAP(const void* file_path, size_t create_size = 0, bool write_access = false);
    ~MMAP();
    
    void* getPointer();
    const void* getPointer() const;
    size_t getSize() const;
    
    char& operator[](size_t index);
    const char& operator[](size_t index) const;
};